package sort;

import java.util.Arrays;

/**
 * @author XY
 * @version 1.0
 * @date 2022/3/16 9:08
 * @Description
 */
public class Leet561 {
    public static int arrayPairSum(int[] nums) {
        Arrays.sort(nums);
        int res = 0;
        for (int i = 0; i < nums.length; i+=2) {
            res+=nums[i];
        }
        return res;
    }

    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        System.out.println(arrayPairSum(arr));
    }
}
